﻿namespace PillBox.Client.Framework
{
    using System;

    public class NavigateResult : IResult
    {
        private object _viewModel;

        public NavigateResult(object viewModel)
        {
            _viewModel = viewModel;
        }

        public event EventHandler Completed;

        public void Execute()
        {
            var navigation = IoC.GetInstance<INavigation>();

            navigation.Navigate(this._viewModel, RaiseCompletedEvent);
        }

        private void RaiseCompletedEvent()
        {
            var handler = this.Completed;

            if (handler != null)
            {
                handler(this, EventArgs.Empty);
            }
        }
    }
}